//查询所有考试跳转到分段页面
<template>
  <div class="exam">
    <div id="searchdiv" style="float: right;margin-bottom: 10px;">
    	<el-input placeholder="请输入内容" v-model="input" class="input-with-select">
    		<el-button @click="searchMessage()" slot="append" icon="el-icon-search"></el-button>
    	</el-input>
    </div>
    <el-table :data="pagination.records" border>
      <el-table-column fixed="left" prop="examName" label="考试名称"></el-table-column>
      <el-table-column prop="avg" label="平均分"></el-table-column>
      <el-table-column prop="max" label="最高分"></el-table-column>
      <el-table-column prop="min" label="最低分"></el-table-column>
      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <el-button @click="toPart(scope.row.examId,scope.row.examName)" type="primary" size="small">查看分段</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pagination.current"
      :page-sizes="[4, 8, 10, 20]"
      :page-size="pagination.size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pagination.total" class="page">
    </el-pagination>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {}, //保存点击以后当前试卷的信息
      pagination: { //分页后的考试信息
        current: 1, //当前页
        total: null, //记录条数
        size: 4 //每页条数
      },
      dialogVisible: false,
	  input:""
    }
  },
  created() {
    this.getPartInfo()
  },
  methods: {
    getPartInfo() {
    	//分页查询所有信息
    	this.$axios('/api/getPart', {
    		params: {
    			keywords: '',
    			page: this.pagination.current,
    			limit: this.pagination.size
    		}
    	}).then(res => {
			console.log("哈哈："+res.data);
    		this.pagination = res.data;
    	}).catch(error => {});
    },
    //改变当前记录条数
    handleSizeChange(val) {
      this.pagination.size = val
      this.getPartInfo()
    },
    //改变当前页码，重新发送请求
    handleCurrentChange(val) {
      this.pagination.current = val
      this.getPartInfo()
    },
	//模糊检索
	searchMessage() {
		this.$axios('/api/getPart', {
			params: {
				keywords: this.input,
				page: this.pagination.current,
				limit: this.pagination.size
			}
		}).then(res => {
			this.pagination = res.data;
		}).catch(error => {});
	
	},
    toPart(examCode,source) { //跳转到分段charts页面
      this.$router.push({path: '/scorePart', query:{examCode: examCode, source: source}})
    }
  },
};
</script>
<style lang="scss" scoped>
.exam {
  padding: 0px 40px;
  .page {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .edit{
    margin-left: 20px;
  }
}

#searchdiv{
    width: 400px;
    display: inline-block;
    margin-left: 74%;
  }
</style>
